<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>user</title>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
</head>
<body>
<form action="/ldl/user" method="post">
    <input name="username" id="username"><br>
    <input id="password" name="password">
    <input type="submit" value="登录">
</form>
<button id="btn" value="点我"></button>
<script>
    $("#btn").click(function () {
        /*$.post("/ldl/user", {"username": "ldl", "password": "123"}, function (result) {
            alert(result);
        })*/

        $.ajax({
            cache: false,
            contentType: "application/json",
            data: JSON.parse({"username": "ldl", "password": "123"}),
            url: "/ldl/user",
            type: "POST",
        })
    })
</script>
</body>
</html>